function getQueryString(params) {
    let url = location.href;

// console.log(url)

    let reg = /(?<=\?).*/

    let r = url.match(reg);

    // console.log(r)
    if (!r) { 
        console.error('没有匹配到url参数')
        return
    } else {

        //对参数进行解码
        r = decodeURI(r[0]);


        if (params) {
            
            let result = r.indexOf(params);
            if (result === -1) { 
                return null
            }
           
            let queryArr = r.split('&');

           
            let obj = {};
            queryArr.forEach(item => {
                let itemArr = item.split('=');
                obj[itemArr[0]] = itemArr[1]
            })
            return obj[params]
        } else { 
            return null
        }
    }
}
